# Throw an error if libwinpthread-1.dll dependency is found
# https://github.com/jrfonseca/drmingw/issues/82

set (CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM windows+pe)
set (CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL objdump)
set (CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND ${CMAKE_OBJDUMP})
file (GET_RUNTIME_DEPENDENCIES
    EXECUTABLES "${TARGET}"
    RESOLVED_DEPENDENCIES_VAR RESOLVED_DEPENDENCIES
    UNRESOLVED_DEPENDENCIES_VAR UNRESOLVED_DEPENDENCIES
)
set (DEPENDENCIES ${RESOLVED_DEPENDENCIES} ${UNRESOLVED_DEPENDENCIES})
list (FILTER DEPENDENCIES INCLUDE REGEX [[^(libgcc|libstdc\+\+|libwinpthread|libssp)]])
if (DEPENDENCIES)
    message (SEND_ERROR "Unexpected ${TARGET} dependencies: ${DEPENDENCIES}")
endif ()
